<!-- jQuery -->
<script src="/js/jquery.min.js"></script>
<!-- jQuery Easing -->
<script src="/js/jquery.easing.1.3.js"></script>
<!-- Bootstrap -->
<script src="/js/bootstrap.min.js"></script>
<!-- Waypoints -->
<script src="/js/jquery.waypoints.min.js"></script>
<!-- Flexslider -->
<script src="/js/jquery.flexslider-min.js"></script>

<script src="/css/fancybox/jquery.fancybox.min.js"></script>



<!-- MAIN JS -->
<script src="/js/main.js"></script>

<!-- Vue -->
<script src="/js/vue.min.js"></script>

<script src="/xe-ajax/dist/xe-ajax.umd.js"></script>

<script src="/editor.md/lib/flowchart.min.js"></script>
<script src="/editor.md/lib/marked.min.js"></script>
<script src="/editor.md/lib/prettify.min.js"></script>
<script src="/editor.md/lib/raphael.min.js"></script>
<script src="/editor.md/lib/underscore.min.js"></script>
<script src="/editor.md/lib/sequence-diagram.min.js"></script>

<script src="/editor.md/editormd.js"></script>


<script>



    const vueC = new Vue({
        el: '#lzpper',
        data: {
            searchStr:'',
            shuffling: null,
            images: null,
            menuC:{
                isActive:true,
                isBlogActive:false,
                isPortfolioActive:false
            }
        },
        methods: {
            /* 控制菜單的選擇 */
            openMenu() {
                let data = <%- JSON.stringify(typeof (isActive) !== 'undefined' ? isActive : '') %>;

                if (!data) {
                    this.menuC.isActive = true;
                } else if (data === 'isBlogActive'){
                    this.menuC.isActive = false;
                    this.menuC.isBlogActive = true;
                    this.menuC.isPortfolioActive = false;
                } else if (data === 'isPortfolioActive') {
                    this.menuC.isActive = false;
                    this.menuC.isBlogActive = false;
                    this.menuC.isPortfolioActive = true;
                } else {
                    this.menuC.isActive = true;
                    this.menuC.isBlogActive = false;
                    this.menuC.isPortfolioActive = false;
                }
            },
            getShuff() {
                XEAjax.post('/shuff/shuff.getAll').then((res) => {
                    if (res.msg === 's') {
                        this.shuffling = res.shuffList;
                        setTimeout(() => {
                            mainFun();
                        },200);
                    }
                }).catch((err) => {});

            },
            getPhoto(){
                XEAjax.post('/photo/photo.getAll')
                    .then((res) => {
                    if (res.msg === 's') {
                        this.images = res.photoList;
                    }
                })
                    .catch((err) => {});
            },
            getLabel(){
                XEAjax.post('/label/label.getAll').then((res) => {
                    if (res.msg === 's') {
                        this.labels = res.labelList;
                    }
                }).catch((err) => {});
            },
            getPost1(url){
                mainFun();
                XEAjax.doGet(url).then(markdown => {
                    const{ data } = markdown;
                    thisEditor = editormd.markdownToHTML("editormd-view", {
                        markdown        :  data,
                        //htmlDecode      : true,       // 开启 HTML 标签解析，为了安全性，默认不开启
                        htmlDecode      : "style,script,iframe",
                        tocm            : true,
                        emoji           : true,
                        taskList        : true,
                        tex             : true,  // 默认不解析
                        sequenceDiagram : true,  // 默认不解析
                    });
                });
            },
            searchOpen(){
                window.location.href = '/search/'+this.searchStr
            }
        },
        mounted() {
            this.$nextTick(() => {
                this.openMenu();
                this.getShuff();
                this.getPhoto();
                //this.getLabel();
                let url = <%- JSON.stringify(typeof (Articles) !== 'undefined' ? Articles : '') %>;
                if (url){
                    console.log('---------------->>>加载文章', JSON.stringify(url));
                    this.getPost1(url[0].content);
                }
            })
        }
    })
</script>
